package ScreensManager
{
	import flash.display.*;
	import ScreensManager.ProjectScreens.GameScreen;
	import ScreensManager.ProjectScreens.IntroductionScreen;
	import ScreensManager.ProjectScreens.MenuScreen;
	import ScreensManager.ProjectScreens.Screens;
	
	
	
	/**
	 * ...
	 * @author ...
	 */
	public class ScreenManager extends MovieClip
	{
		/**
		 * determina a tela atual
		 */
		private static var currentScreen:Screen;
		
		public function ScreenManager() 
		{
			
		}
		
		/**
		 * Retorna a tela atual
		 * @return currentScreen:Screen
		 */
		public static function getCurrentScreen():Screen
		{
			return currentScreen;
		}
		
		/**
		 * realiza a troca de telas
		 * @param	screen = tela que será desenhada
		 */
		public static function setCurrentScreen(screen:int):void 
		{
			/* adicione mais um case para uma tela nova ser desenhada
			 * Exemplo:
				 * case Screens.NOVA_TELA
				 * clearScreen();
				 * var novaTela:TelaNova = new TelaNova();
				 * novaTela.drawScreen();
				 * currentScreen = novaTela
				 * brea;
			 */
			
			switch(screen)
			{
				case Screens.INTRODUCTION_SCREEN:
					clearScreen();
					var introductionScreen:IntroductionScreen = new IntroductionScreen();
					introductionScreen.drawScreen();
					currentScreen = introductionScreen;
				break;
				
				case Screens.MENU_SCREEN:
					clearScreen();
					var menuScreen:MenuScreen = new MenuScreen();
					menuScreen.drawScreen();
					currentScreen = menuScreen;
				break;
				
				case Screens.GAME_SCREEN:
					clearScreen();
					var gameScreen:GameScreen = new GameScreen();
					gameScreen.drawScreen();
					currentScreen = gameScreen;
				break;
			}
		}
		
		/**
		 * remove a tela atual.
		 */
		private static function clearScreen():void
		{
			if (currentScreen)
			{
				currentScreen.removeListeners();
				Main.getInstance().removeChild(currentScreen);
				currentScreen = null;
			}
		}
	}

}